<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Label
 *
 * @property int $id 主键
 * @property string|null $key key
 * @property string|null $value 值
 * @property string|null $description 说明
 * @property int $state 状态
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 更新时间
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereKey($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereState($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Label whereValue($value)
 * @mixin \Eloquent
 */
class Label extends Model
{
    protected $table = 'label';
    protected $primaryKey = 'id';
    protected $fillable = ['key', 'value', 'description', 'state'];

    public static function updateCache(){
        $labels = Label::whereState(1)->get()->pluck('value','key');
        cache()->forever('labels', $labels);
    }
}
